import random

def fib(n):
    """Print a Fibonacci series up to n."""
    a, b = 0, 1
    while a < n:
        print(a, end = ' ')
        a, b = b, a+b
        print()

#fib(200)

def fib2(n):
    """return a list containing the Fibonacci series up to n."""
    result = []
    a, b = 0, 1
    while a < n:
        result.append(a)
        a, b = b, a+b
        #print(a,b)
    return result

f100 = fib2(10)
#f100
print(f100)

#print(random.uniform(1, 9) // 1)

#尾递归相关
def fact(n):
    return fact_iter(n, 1)

def fact_iter(num, product):
    if num == 1:
        return product
    return fact_iter(num - 1, num * product)

#print(fact(1000))

def testFile():
    for line in open('test.txt'):
        print(line)

#testFile()

# list测试 
L = ['Hello', 'World', 'IBM', 'Apple']
[s.lower() for s in L]
